<template>
  <div class="agreement-box flex js-ct align-center">
    <div class="agreement person-bg radius-8" v-if="state.data.protocol_title">
      <div class="agree-header bdb-borderBase">
        <div class="text-t1 text-18 mb-8">{{ state.data.protocol_title }}</div>
        <div class="textperson-t3 text-12">
          {{ $t("user.date") }}：{{ state.data.protocol_push_time }}
        </div>
      </div>
      <div
        class="agreement-content text-left"
        v-html="state.data.protocol_content"
      ></div>
    </div>
    <div class="nothing" v-else>
      <img src="@/assets/images/nothing.png" alt="" />
      <span class="text-18 text-t2">{{ $t("feedback.none") }}</span>
    </div>
  </div>
</template>

<script>
import { computed, onMounted, reactive, watch } from "vue";
import { getProtocol } from "@/api/article";
import { useRoute } from "vue-router";
export default {
  name: "Agreementall",
  setup() {
    const state = reactive({
      param: {},
      data: {},
    });

    /**
     * methods
     */
    const $route = useRoute();
    const getType = computed(() => {
      return $route.query.name;
    });
    watch(getType, (route) => {
      if (route) {
        state.param.protocol_type_tag = route;
        getData();
      }
    });
    onMounted(() => {
      state.param.protocol_type_tag = $route.query.name;
      getData();
    });
    const getData = () => {
      getProtocol(state.param)
        .then((res) => {
          state.data = res.data;
        })
        .catch(() => {
          state.data = {};
        });
    };
    return {
      state,
      getData,
    };
  },
};
</script>

<style scoped lang="less">
.agreement-box {
  width: 100%;
  min-height: 100vh;
  padding-bottom: 60px;
}
.agreement {
  width: 1120px;
  min-height: 747px;
}
.agree-header {
  width: 100%;
  height: 75px;
  padding-top: 17px;
  box-sizing: border-box;
}
.mb-8 {
  margin-bottom: 8px;
}
.agreement-content {
  width: 100%;
  padding: 20px 30px;
  box-sizing: border-box;
  letter-spacing: 1px;
  line-height: 16.8px;
  word-wrap: break-all;
}
.nothing {
  width: 200px;
  img {
    width: 200px;
    margin-bottom: 20px;
  }
}
</style>
